package com.atguigu.gulimail.Controller;

import com.atguigu.gulimail.Service.PayService;
import com.atguigu.gulimail.Service.impl.QueryGrantTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Guo 2022/9/7 9:29:10
 */
@RestController
@RequestMapping("/xiaoniu")
public class PayController {

    @Resource(name = "payService")
    private PayService payService;

    @Resource(name = "queryGrantTypeService")
    private QueryGrantTypeService queryGrantTypeService;

    /**
     * 支付接口
     *
     * @param channel 渠道
     * @param amount  消费金额
     * @return String 返回消费结果
     * @author Ye hongzhi
     * @date 2020/4/5
     */
    @RequestMapping("/pay")
    public String pay(@RequestParam(name = "channel") String channel,
                      @RequestParam(name = "amount") String amount
    ) throws Exception {
        return payService.payByStrategy(channel, amount);
    }




    @GetMapping("/payByMap")
    public String payByMap(String channel,String amount) {
        return queryGrantTypeService.getResult(channel,amount);
    }

}
